<template>
	<div class="counter-warp">
		<button hover-class="clicked" class="login-button" @click="handleLogin">登录</button>
	</div>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import {
		genTestUserSig
	} from '../../common/static/utils/GenerateTestUserSig'
	export default {
		data() {
			return {
				password: '',
				userIDList: new Array(30).fill().map((item, idx) => ('user' + idx)),
				selectedIndex: 1,
				loading: false
			}
		},
		computed: {
			...mapState({
				myInfo: state => state.user.myInfo
			})
		},
		onUnload() {
			this.loading = false
		},
		methods: {
			// 点击登录进行初始化
			handleLogin() {
				const userID = this.userIDList[this.selectedIndex]
				this.login(userID)
			},
			login(userID) {
				uni.$TUIKit.login({
					userID,
					userSig: genTestUserSig(this.userIDList[this.selectedIndex]).userSig
				}).then(() => {}).catch(() => {
					this.loading = false
				})
			},
			choose(event) {
				this.selectedIndex = Number(event.mp.detail.value)
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
